FROM node:slim as build-stage
WORKDIR /app
COPY package.json .
RUN npm i -g pnpm
RUN pnpm config set registry https://registry.npmmirror.com/
RUN pnpm i
COPY . .
RUN pnpm run build && ls /app/dist

# production stage
FROM node:slim as production-stage

COPY --from=build-stage /app/dist /app
COPY --from=build-stage /app/package.json /app/package.json

WORKDIR /app
RUN npm i -g pnpm
RUN pnpm config set registry https://registry.npmmirror.com/
RUN pnpm i --only=production
EXPOSE 3005
CMD ["node", "/app/main.js"]